<?php
/**
 * 杂项
 * Enter description here ...
 * @author nijn
 *
 */
class MiscController extends FrontController{
	/**
	 *  Error500Action 500服务器内部错误
	 *  Error404Action 404服务器内部错误
	 *  Error403Action 403服务器内部错误
	 */
    public $layout = '//layouts/platform_column';
	public function actions(){
		return array(
			'captcha'=>array(
				'class'=>'CCaptchaAction',
				'backColor'=>0xFFFFFF,
				'minLength' => 4,
				'maxLength' => 4,
				'width' => '80',
				'height' => '40',
				'testLimit' => 0
			),
		);
	}
	//建设中
	public function actionBuild(){
		$this->render('build');
	}
	
	public function actionFindpass(){
		if (!empty($_POST)) {
			Yii::app()->findPwd->run($_POST['worker_name'],$_POST['email']);
		}
		$this->render('findpass');
	}
	
 	public function actionResetPwd($token) {
        $info = FindPassword::model()->findByAttributes(array('token'=>$token));
        $model = new MemberForm();

        $message = '';
        if(!empty($info)){
            if(isset($_POST['MemberForm'])){
                $model->attributes = $_POST['MemberForm'];
                if($model->save()){
                   Yii::app()->findPwd->updateState($token);
                   $this->redirect(Yii::app()->createUrl('provide/index/login'));
                }
            }else if($info->state != 0){
                $message = '对不起，您的邮件已过时，请重新申请！';
            }
        }else{
            $message = '对不起，令牌验证错误！';
        }
        Yii::app()->user->setFlash('findPwd',$message);
        $this->render('resetPwd',array(
            'model'=>$model,
        ));
    }
    
    /*
     * 注册分类
     */
    public function actionRegType(){
        $this->render('regType');
    }
    public function actionError500(){
        $this->render('error500');
    }
    public function actionError404(){
        $this->render('error404');
    }
    public function actionError403(){
        $this->render('error403');
    }
	
}

?>